package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sc.nft.entity.vo.UserReceiveIntegralVo;
import com.sc.nft.mapper.UserReceiveIntegralMapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserReceiveIntegral;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * (sc_user_receive_integral)数据DAO
 *
 * @author rdg
 * @since 2022-05-30 10:42:05
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserReceiveIntegralDao extends ServiceImpl<UserReceiveIntegralMapper, UserReceiveIntegral> {
    @Resource
    UserReceiveIntegralMapper userReceiveIntegralMapper;
    public List<UserReceiveIntegralVo> findByUserId(Long userId) {
       return userReceiveIntegralMapper.findByUserId(userId);
    }
    public UserReceiveIntegral getUserReceiveIntegral(Long userId, Long code){
        LambdaQueryWrapper<UserReceiveIntegral> userReceiveWrapper = new LambdaQueryWrapper<>();
        userReceiveWrapper.eq(UserReceiveIntegral::getUserId,userId).eq(UserReceiveIntegral::getIntegralTaskId,code);
        userReceiveWrapper.eq(UserReceiveIntegral::getIsReceive,Boolean.TRUE);
        userReceiveWrapper.last("limit 1");
        return getOne(userReceiveWrapper);
    }

}